#include <signal.h>
#include <iostream>
#include<unistd.h>


void sigcb(int signal){
     std::cout<<"2 is SIGINT which Accepted"<<std::endl;
     sleep(1);
}
int main(){



    struct sigaction sa_usr;
    sa_usr.sa_flags = 0;
    sa_usr.sa_handler = sigcb;  
    sigaction(SIGINT, &sa_usr, NULL);
    while(true){
        sleep(1);
        std::cout<<"I am running my pid is"<<getpid()<<std::endl;
    }
    /*
    signal(2,sigcb);
    while(true){
        sleep(1);
        std::cout<<"I am running my pid is"<<getpid()<<std::endl;
    }
    return 0;
    */
   //signal的使用方法
}